//
//  FKTeamAwardCell.m
//  WanTao
//
//  Created by Macbook Pro on 2019/3/14.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKTeamAwardCell.h"
#import "FKTeamAward.h"

@interface FKTeamAwardCell ()

@property (nonatomic, weak) UIImageView *avatarView;
@property (nonatomic, weak) UILabel *nameLabel;
@property (nonatomic, weak) UILabel *dateLabel;
@property (nonatomic, weak) UILabel *superNameLabel;
@property (nonatomic, weak) UILabel *positionLabel;
@property (nonatomic, weak) UILabel *priceLabel;

@end

@implementation FKTeamAwardCell

- (void)setupSubviews
{
    [super setupSubviews];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UIImageView *avatarView = [[UIImageView alloc] init];
    [self.contentView addSubview:avatarView];
    self.avatarView = avatarView;
    [avatarView fk_viewCornerRadius:fk_adjustW(15) borderWidth:0 borderColor:nil];
    
    UILabel *nameLabel = [UILabel fk_labelWithFont:fk_adjustFont(13) textColor:fkColor333333];
    [self.contentView addSubview:nameLabel];
    self.nameLabel = nameLabel;
    
    UILabel *dateLabel = [UILabel fk_labelWithFont:fk_adjustFont(10) textColor:fkColor999999];
    [self.contentView addSubview:dateLabel];
    self.dateLabel = dateLabel;
    
    UILabel *superNameLabel = [UILabel fk_labelWithFont:fk_adjustFont(13) textColor:fkColor333333];
    [self.contentView addSubview:superNameLabel];
    self.superNameLabel = superNameLabel;
    
    UILabel *positionLabel = [UILabel fk_labelWithFont:fk_adjustFont(11) text:nil];
    [self.contentView addSubview:positionLabel];
    self.positionLabel = positionLabel;
    [positionLabel fk_viewCornerRadius:3 borderWidth:0 borderColor:nil];
    
    UILabel *priceLabel = [UILabel fk_labelWithFont:fk_adjustFont(13) textColor:fkMainColor];
    [self.contentView addSubview:priceLabel];
    self.priceLabel = priceLabel;
    
    [avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(fk_adjustW(30));
        make.left.offset(12);
        make.centerY.offset(0);
    }];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(avatarView);
        make.left.equalTo(avatarView.mas_right).offset(8);
    }];
    [dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(nameLabel);
        make.bottom.equalTo(avatarView);
    }];
    [superNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_centerX);
        make.centerY.offset(0);
    }];
    [positionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(superNameLabel.mas_right).offset(2);
        make.centerY.offset(0);
    }];
    [priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-12);
        make.centerY.offset(0);
    }];
}

- (void)setData:(id)data
{
    [super setData:data];
    
    FKTeamAward *model = data;
    
    [self.avatarView sd_setImageWithURL:[NSURL URLWithString:model.child_avatar] placeholderImage:kDefaultAvatar];
    self.nameLabel.text = model.child_nickname;
    self.dateLabel.text = model.addTime;
    self.superNameLabel.text = model.child_sp_nickname;
    self.positionLabel.text = model.levelName;
    self.positionLabel.textColor = model.levelTitleColor;
    self.positionLabel.backgroundColor = model.levelBgColor;
    self.priceLabel.text = model.priceStr;
}

@end
